package cn.bsb.service.backstage;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import cn.bsb.dao.backendUserMapper;
import cn.bsb.pojo.BackendUser;

@Service
public class backendUserService {
	@Autowired
	private backendUserMapper backendUser;
	
	public BackendUser getOne(String userCode,String password) {
		return backendUser.findOne(userCode, password);
	}
	public List<BackendUser> getList(){
		return backendUser.getList();
	}
	
	public PageInfo<BackendUser> getList(int pageNum, int pageSize){
		PageHelper.startPage(pageNum, pageSize);
		List<BackendUser> list = backendUser.getList();
		PageInfo<BackendUser> page = new PageInfo<BackendUser>(list);
		return page;
	}
	
	public PageInfo<BackendUser> getName(int pageNum, int pageSize,String name){
		PageHelper.startPage(pageNum, pageSize);
		List<BackendUser> list = backendUser.getName(name);
		PageInfo<BackendUser> page = new PageInfo<BackendUser>(list);
		return page;
	}
	
	public boolean deleteUserById(Integer delId) throws Exception {
		boolean flag = true;
			if(backendUser.deleteUserById(delId) < 1)
				flag = false;
		return flag;
	}
	
	public boolean add(BackendUser user)throws Exception {
		boolean flag = false;
		if(backendUser.add(user)>0) {
			flag=true;
		}
		return flag;
		
	}
	
	
}
